package com.ruoyi.show.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.show.domain.PublisherStats;
import com.ruoyi.show.service.IPublisherStatsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 出版社数据Controller
 * 
 * @author ruoyi
 * @date 2025-09-08
 */
@RestController
@RequestMapping("/show/publisher")
public class PublisherStatsController extends BaseController
{
    @Autowired
    private IPublisherStatsService publisherStatsService;

    /**
     * 查询出版社数据列表
     */
    @PreAuthorize("@ss.hasPermi('show:publisher:list')")
    @GetMapping("/list")
    public TableDataInfo list(PublisherStats publisherStats)
    {
        startPage();
        List<PublisherStats> list = publisherStatsService.selectPublisherStatsList(publisherStats);
        return getDataTable(list);
    }

    /**
     * 导出出版社数据列表
     */
    @PreAuthorize("@ss.hasPermi('show:publisher:export')")
    @Log(title = "出版社数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PublisherStats publisherStats)
    {
        List<PublisherStats> list = publisherStatsService.selectPublisherStatsList(publisherStats);
        ExcelUtil<PublisherStats> util = new ExcelUtil<PublisherStats>(PublisherStats.class);
        util.exportExcel(response, list, "出版社数据数据");
    }

    /**
     * 获取出版社数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('show:publisher:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(publisherStatsService.selectPublisherStatsById(id));
    }

    /**
     * 新增出版社数据
     */
    @PreAuthorize("@ss.hasPermi('show:publisher:add')")
    @Log(title = "出版社数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PublisherStats publisherStats)
    {
        return toAjax(publisherStatsService.insertPublisherStats(publisherStats));
    }

    /**
     * 修改出版社数据
     */
    @PreAuthorize("@ss.hasPermi('show:publisher:edit')")
    @Log(title = "出版社数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PublisherStats publisherStats)
    {
        return toAjax(publisherStatsService.updatePublisherStats(publisherStats));
    }

    /**
     * 删除出版社数据
     */
    @PreAuthorize("@ss.hasPermi('show:publisher:remove')")
    @Log(title = "出版社数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(publisherStatsService.deletePublisherStatsByIds(ids));
    }
}
